package cz.cvut.fel.gfupan.gui.execution;

import javax.swing.text.JTextComponent;

public class AutoFill implements Executable {

    private JTextComponent comp;
    private JTextComponent owning;

    public AutoFill(JTextComponent owning, JTextComponent declination) {
        this.owning = owning;
        this.comp = declination;
    }

    @Override
    public String execute() {
        if (!owning.getText().equals("") || comp.isFocusOwner()) {
            return owning.getText();
        }
        return comp.getText();
    }
}